package com.aiguigu.sort;

public class InsertSort {
    public static void main(String[] args) {
        int arr[] = {10,14,-1,5,6,55,47};
        int index = 0;
        int number;
        for (int i = 0; i <arr.length-1 ; i++) {
            number =arr[i+1];
            index=i;
           while (index>=0&&number<arr[index]){
               arr[index+1] = arr[index];
               index --;
           }
            if (index!=i){
                arr[index+1] = number;
            }
        }
        for (int i : arr) {
            System.out.print(i+" ");
        }
    }
}
